package com.example.webdemo.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author zp
 * @version 1.0
 * @description: TODO
 * @date 2023/6/24 17:12
 */
@Configuration
public class CorsConfig implements WebMvcConfigurer {

    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**").
                allowedOrigins("http://localhost:8080").
                allowedMethods("GET", "HEAD", "POST","PUT", "DELETE", "OPTIONS").
                allowedHeaders("Content-Type","Access-Control-Allow-Headers","Authorization","X-Requested-With").
                allowCredentials(true);
    }
}
